<?php

error_reporting(7);
ini_set("display_errors",false);
require './db.class.php';

$ac = htmlspecialchars($_REQUEST['ac']);
$db = new db('103.243.25.246','root','19891016@vps','app','','UTF8');
$renshu =array(
0=>'抱歉，无法',
1=>'1 人参加',
2=>'2 人参加',
3=>'3 人参加',
4=>'4 人参加',
5=>'5 人参加',
6=>'6 人参加',
7=>'7 人参加',
8=>'8 人参加',
9=>'9 人参加'
);

if($ac == 'wreply'){
    $time = time();
    $name = htmlspecialchars($_POST['name']);
    $phone = htmlspecialchars(trim($_POST['phone']));
    $num = intval(trim($_POST['num']));
    $content = htmlspecialchars(trim($_POST['content']));
    $num_str = $renshu[$num];
    $sql = "insert into members(`name`,`phone`,`num`,`content`,`addtime`) values('$name','$phone','$num_str','$content',$time)";
    if($db->query($sql)){
        echo '{"code":200}';exit();
    }else{
        echo '{"code":404}';exit();
    }
    
}
if($ac == 'read'){
    $sql = "select * from members";
    $db->query($sql);
    $result = $db->fetch_all();
    print_r($result);
}
?>